# -*- coding: utf-8 -*-
"""
月度比赛模型
"""
from app import db
from datetime import datetime

class MonthlyCompetition(db.Model):
    __tablename__ = 'monthly_competitions'
    id = db.Column(db.BigInteger, primary_key=True)
    name = db.Column(db.String(64), nullable=False)
    description = db.Column(db.Text)
    start_date = db.Column(db.Date, nullable=False)
    end_date = db.Column(db.Date, nullable=False)
    created_at = db.Column(db.DateTime, default=datetime.utcnow)
    group_choices = [('A', '甲组'), ('B', '乙组'), ('C', '丙组')]
    # 可扩展字段：如比赛类型、地点等

class MonthlyCompetitionSignup(db.Model):
    __tablename__ = 'monthly_competition_signups'
    id = db.Column(db.BigInteger, primary_key=True)
    competition_id = db.Column(db.BigInteger, db.ForeignKey('monthly_competitions.id'), nullable=False)
    student_id = db.Column(db.BigInteger, db.ForeignKey('users.id'), nullable=False)
    group = db.Column(db.Enum('A', 'B', 'C'), nullable=False, comment='报名组别')
    signup_time = db.Column(db.DateTime, default=datetime.utcnow)
    # 可扩展字段：如报名状态等

    competition = db.relationship('MonthlyCompetition', backref='signups')
    student = db.relationship('User')
